<?php
include_once("./function.php");
$sql="select * from ts_product_cate";
$res=mysqli_query($link,$sql);
if(is_object($res))
{
	if((mysqli_num_rows($res))>0)
	{
		$pro=array();
		while($list=mysqli_fetch_assoc($res))
		{
			$pro[]=$list;
		}
		//print_r($pro);die;//Array ( [0] => Array ( [pc_id] => 1 [pc_fid] => 0 [pc_name] => 服装 [pc_level] => 1 [ifshow] => 0 ) )
	}
}
//无线分类
function card($arr,$pc_fid)
{
	static $new=array();
	foreach($arr as $v)
	{
		if($v['pc_fid']==$pc_fid)
		{
			$new[]=$v;
			card($arr,$v['pc_id']);
		}
	}
	return $new;
}
$pro=card($pro,0);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>主体部分</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="skin/css/base.css" />
<link rel="stylesheet" type="text/css" href="skin/css/main.css" />
</head>
<body leftmargin="8" topmargin='8'>
<form action="do_product_cate_add.php" method="get">
<table width="98%" align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px;margin-top:8px;">
  <tr>
    <td background="skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' colspan="2"><span><img src='skin/images/frame/arr3.gif' style='margin-right:10px;'>添加商品分类</span></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>
		<table style="margin-bottom:8px;margin-top:8px;margin-left:20px;">
			 <tr>
				<td width="100px;">上级分类:</td>
				<td>
					<select name="id">
					<option value="0">顶级分类</option>
					<?php foreach($pro as $v){?>
					<option value="<?=$v['pc_id']?>"><?=str_repeat("&nbsp;",6*($v['pc_level']-1)).$v['pc_name']?></option>
					<?php }?>
					</select>
				</td>
			  </tr>
			   <tr>
				 <td>分类名称:</td>
				 <td><input type="text" name="pname" value=""/></td>
			   </tr>
			   <tr>
				 <td>首页是否显示</td>
				 <td><input type="radio" name="show" value="show" checked>显示 <input type="radio" name="show" value="noshow"> 不显示</td>
			   </tr>
			   <tr>
				 <td colspan="2" align="center" height="40px">
					<input type="submit" name="sub" value="添加"/>
				 </td>
			   </tr>
		</table>
	</td>
  </tr>
</table>
</form>
</body>
</html>

